home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / ddj0897.zip / DYN401.ZIP / class / strdict.d < prev    next >
Text File  |  1996-04-01  |  2KB  |  100 lines

  1.  
  2.  
  3.  
  4. /*                                      
  5.  *
  6.  *      Copyright (c) 1993-1996 Algorithms Corporation
  7.  *      3020 Liberty Hills Drive
  8.  *      Franklin, TN 37067
  9.  *
  10.  *      ALL RIGHTS RESERVED.
  11.  *
  12.  *      
  13.  *      
  14.  */
  15.  
  16.  
  17.  
  18. defclass  StringDictionary : Set  {
  19.     init:    init_class;
  20. };
  21.  
  22.  
  23. #include "set1.h"
  24.  
  25. #define LTYPE    2    /*  lookup type    */
  26.  
  27. static    gLookup_t    Lookup;        /*  locally cached  */
  28.  
  29. imeth    gAddStr, <vAdd> (char *key, value)
  30. {
  31.     ChkArgNul(value, 3);
  32.     return Lookup(self, (object) key, HT_ADD, 0, LTYPE, value);
  33. }
  34.  
  35. imeth    gFindValueStr, <vFindValue> (char *key)
  36. {
  37.     object    x = Lookup(self, (object) key, HT_FIND, 0, LTYPE, NULL);
  38.     return x ? gValue(x) : x;
  39. }
  40.  
  41. imeth    gFindStr, <vFind> (char *key)
  42. {
  43.     return Lookup(self, (object) key, HT_FIND, 0, LTYPE, NULL);
  44. }
  45.  
  46. imeth    gChangeValueWithStr, <vChangeValue> (char *key, object val)
  47. {
  48.     object    x;
  49.     ChkArgNul(val, 3);
  50.     x = Lookup(self, (object) key, HT_FIND, 0, LTYPE, NULL);
  51.     return x ? gChangeValue(x, val) : x;
  52. }
  53.  
  54. imeth    gFindAddStr, <vFindAdd> (char *key, object value)
  55. {
  56.     ChkArgNul(value, 3);
  57.     return Lookup(self, (object) key, HT_FINDADD, 0, LTYPE, value);
  58. }
  59.  
  60. imeth    object    gDispose()
  61. {
  62.     return gDispose1(self);
  63. }
  64.  
  65. imeth    object    gDisposeAllNodes()
  66. {
  67.     return gDisposeAllNodes1(self);
  68. }
  69.  
  70. imeth    gRemoveStr, <vRemove> (char *key)
  71. {
  72.     return Lookup(self, (object) key, HT_DELETE, 1, LTYPE, NULL);
  73. }
  74.  
  75. imeth    gDeepDisposeStr, gDisposeStr (char *key)
  76. {
  77.     return Lookup(self, (object) key, HT_DELETE, 2, LTYPE, NULL);
  78. }
  79.  
  80. static    void    init_class(void)
  81. {
  82.     Lookup = imcPointer(Set, gLookup);
  83. }
  84.  
  85.  
  86.  
  87. /*                                      
  88.  *
  89.  *      Copyright (c) 1993-1996 Algorithms Corporation
  90.  *      3020 Liberty Hills Drive
  91.  *      Franklin, TN 37067
  92.  *
  93.  *      ALL RIGHTS RESERVED.
  94.  *
  95.  *      
  96.  *      
  97.  */
  98.  
  99.  
  100.